﻿<Window x:Class="BookReader.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cmd="clr-namespace:BookReader;assembly=BookReader"
    xmlns:ucc="clr-namespace:BookReader.Controls"    
    MinHeight="400" MinWidth="1100"
    WindowStyle="None" AllowsTransparency="True" Background="Transparent" 
    ResizeMode="CanResizeWithGrip" WindowState="Normal" 
    Loaded="Window_Loaded" Closing="Window_Closing" SourceInitialized="Window_SourceInitialized">
    <Grid Name="MainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="52" />
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        
        <Border Grid.RowSpan="4" Background="{DynamicResource WindowBackgroundBrush}" CornerRadius="5"
                VerticalAlignment="Stretch" MouseLeftButtonDown="Window_MouseLeftButtonDown" 
                BorderThickness="1" BorderBrush="Black"></Border>
        <Button Panel.ZIndex="100" Style="{DynamicResource closeButton}" Margin="756,7,11,0" Name="closeButton"
                HorizontalAlignment="Right" VerticalAlignment="Top" Height="10"
                Command="ApplicationCommands.Close" ToolTip="Exit"></Button>
        <Button Panel.ZIndex="100" Style="{DynamicResource maximizeButton}" Margin="737,7,28,4" Name="maximizeButton" 
                HorizontalAlignment="Right" VerticalAlignment="Top" Height="10"
                Click="maximizeButton_Click" ToolTip="Maximize"></Button>
        <Button Panel.ZIndex="100" Style="{DynamicResource minimizeButton}" Margin="0,7,44,4" Name="minimizeButton" 
                HorizontalAlignment="Right" VerticalAlignment="Top" Height="10"
                Click="minimizeButton_Click" ToolTip="Minimize"></Button>
        
        <DockPanel Grid.Row="0" Grid.RowSpan="2" Margin="3" LastChildFill="True" MouseLeftButtonDown="Window_MouseLeftButtonDown">
            <Button Name="btnOpen" MinWidth="60" Margin="5,0,15,0" HorizontalAlignment="Stretch" Command="ApplicationCommands.Open"
                    ToolTip="Open a book everywhere on your disks">
                <StackPanel Orientation="Vertical" Margin="0">
                    <Image Width="32" Source="Resources\Images\open_folder.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Open</Label>
                </StackPanel>
            </Button>
            <Button Name="btnFullScreen" MinWidth="60" Margin="5,0,5,0" HorizontalAlignment="Stretch" Click="btnFullScreen_Click" ToolTip="Put Book Reader in full screen mode and hide explorers">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\ecran.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Full screen</Label>
                </StackPanel>
            </Button>
            <Button Name="btnRefresh" MinWidth="60" Margin="5,0,5,0" HorizontalAlignment="Stretch" Click="btnRefresh_Click" ToolTip="Refresh the catalog by a full scan of the folder">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\refresh.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Refresh</Label>
                </StackPanel>
            </Button>
            <Button Name="btnOptions" MinWidth="60" Margin="5,0,15,0" Click="btnOptions_Click" ToolTip="Display the options dialog" >
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\tools.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Options</Label>
                </StackPanel>
            </Button>
            
            <Button Name="bntFitWidth" MinWidth="60" Margin="5,0,5,0" Click="btnFitWidth_Click" ToolTip="Fit the display to the page width">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\FitWidth.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Width</Label>
                </StackPanel>
            </Button>
            <Button Name="bntFitHeight" MinWidth="60" Margin="5,0,15,0" Click="btnFitHeight_Click" ToolTip="Fit the display to the page height">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\FitHeight.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Height</Label>
                </StackPanel>
            </Button>
            <Button Name="bntConvertPDF" MinWidth="60" Margin="5,0,15,0" ToolTip="Convert a PDF to CBZ/CBR" Click="bntConvertPDF_Click">
                <StackPanel Orientation="Vertical" Margin="2">
                <Image Width="32" Source="Resources\Images\acroread.png"></Image>
                <Label VerticalAlignment="Center" HorizontalAlignment="Center">Convert</Label>    
                </StackPanel>
            </Button>
            <Button Name="bntGoto" MinWidth="60" Margin="5,0,5,0" Click="btnGoto_Click" ToolTip="Goto a page in the book">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\GotoPage.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Goto</Label>
                </StackPanel>
            </Button>
            <Button Name="bntQuit" MinWidth="60" Margin="5,0,5,0" Command="ApplicationCommands.Close" ToolTip="Close Book Reader">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\exit.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Exit</Label>
                </StackPanel>
            </Button>
            <ucc:DropDownButton x:Name="bntTheme" MinWidth="60" Margin="15,0,5,0" ToolTip="Change the display style">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\Style.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">Style</Label>
                </StackPanel>
                <ucc:DropDownButton.DropDown>
                    <ContextMenu>
                        <MenuItem Header="Black" Command="cmd:MainWindow.ChangeThemeCmd" CommandParameter="Black"/>
                        <MenuItem Header="Blue" Command="cmd:MainWindow.ChangeThemeCmd" CommandParameter="Blue"/>
                        <MenuItem Header="Silver" Command="cmd:MainWindow.ChangeThemeCmd" CommandParameter="Silver"/>
                    </ContextMenu>
                </ucc:DropDownButton.DropDown>
            </ucc:DropDownButton>
            <Button Name="bntAbout" MinWidth="60" Margin="15,0,5,0" Click="btnAbout_Click" ToolTip="About the author and Acknowlegdments">
                <StackPanel Orientation="Vertical" Margin="2">
                    <Image Width="32" Source="Resources\Images\info.png"></Image>
                    <Label VerticalAlignment="Center" HorizontalAlignment="Center">About</Label>
                </StackPanel>
            </Button>
            <StackPanel>
                <Label>Search filter :</Label>
                <TextBox Margin="5,5,5,5" Name="tbSearch" Height="21"></TextBox>
            </StackPanel>    
        </DockPanel>
        <Grid Grid.Row="2" Margin="5,0,5,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
        <ListBox Grid.Column="0" BorderThickness="0"
              VirtualizingStackPanel.IsVirtualizing="True"
              IsSynchronizedWithCurrentItem="True"
              Name="CatalogListBox" 
              SelectionMode="Single" 
              ItemsSource="{Binding Books}" 
              ItemTemplate="{DynamicResource PublicTemplate}"
              SelectedIndex="0"
              Style="{DynamicResource CatalogCoverStyle}"
              MouseDoubleClick="CatalogListBox_MouseDoubleClick">
            <ListBox.ContextMenu>
            <ContextMenu>
                    <MenuItem Header="Read" Command="cmd:MainWindow.ReadCmd" />
                    <MenuItem Header="Mark as (un)read" Command="cmd:MainWindow.MarkReadCmd" />
                <Separator></Separator>
                    <MenuItem Header="Goto bookmark" Command="cmd:MainWindow.GotoBookmarkCmd" CommandParameter="LIST"/>
                    <MenuItem Header="Clear bookmark" Command="cmd:MainWindow.ClearBookmarkCmd" CommandParameter="LIST"/>
                <Separator></Separator>
                    <MenuItem Command="cmd:MainWindow.ProtectCmd"/>
                <Separator></Separator>
                    <MenuItem Header="Delete" Command="ApplicationCommands.Delete"/>
            </ContextMenu>
        </ListBox.ContextMenu>
        </ListBox>
        <ucc:GridSplitterExpander Grid.Column="1" Orientation="Vertical" GridIndex="0" 
            x:Name="Splitter" Background="{DynamicResource ControlBackgroundBrush}"/>
        <ucc:PageViewer x:Name="SimplePageView" Grid.Column="2" 
                      PageChanged="SimplePageView_PageChanged"
                      ZoomChanged="SimplePageView_ZoomChanged" >
            <ucc:PageViewer.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Set bookmark" Command="cmd:MainWindow.BookmarkCmd"/>
                    <MenuItem Header="Goto bookmark" Command="cmd:MainWindow.GotoBookmarkCmd" CommandParameter="VIEW"/>
                    <MenuItem Header="Clear bookmark" Command="cmd:MainWindow.ClearBookmarkCmd" CommandParameter="VIEW"/>
                </ContextMenu>
            </ucc:PageViewer.ContextMenu>
        </ucc:PageViewer>
        </Grid>
        <DockPanel Grid.Row="3" Margin="3" Background="{DynamicResource WindowBackgroundBrush}" LastChildFill="True">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.6*" />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="1*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Name="BookInfo" VerticalAlignment="Center" HorizontalAlignment="Stretch"
                       IsHitTestVisible="False" Margin="5,0,0,0" ToolTip="Number of books in the catalog"
                       Content=""/>
                <Label Grid.Column="1" Name="PageInfo" VerticalAlignment="Center" HorizontalAlignment="Stretch"
                       IsHitTestVisible="False" Margin="5,0,0,0" ToolTip="Get information about the image cache"
                       Content="" />
                <Label Grid.Column="2" Name="CacheInfo" VerticalAlignment="Center" HorizontalAlignment="Stretch" IsHitTestVisible="False"
                       Margin="5,0,0,0" ToolTip="Display the current page displayed"
                       Content=""/>
                <DockPanel Grid.Column="3" HorizontalAlignment="Stretch" LastChildFill="True">
                    <Label Name="zoomPercent" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                           Content="{Binding ElementName=zoomSlider, Path=Value}"></Label>
                    <Label Margin="5,0,5,0" VerticalAlignment="Center" HorizontalAlignment="Left">%</Label>
                    <Slider Name="zoomSlider" Minimum="1" Maximum="400" SmallChange="1" TickPlacement="None"
                        Value="100" VerticalAlignment="Center" ValueChanged="Slider_ValueChanged"
                        HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
                        LargeChange="10" IsSnapToTickEnabled="True" Focusable="False"></Slider>
                </DockPanel>
            </Grid>    
        </DockPanel>
    </Grid>
</Window>
